//
//  TYHomeFunctionFirstCell.m
//  爱鲜蜂
//
//  Created by 李田 on 16/11/8.
//  Copyright © 2016年 tianyao. All rights reserved.
//

#import "LBHomeFunctionFirstCell.h"
#import "LBBtnView.h"

@implementation LBHomeFunctionFirstCell
- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    //    MARK: 设置背景颜色
    self.backgroundColor = [UIColor whiteColor];
    
    //    MARK: 创建滚动图片View
    UIView *cycleV = [[UIView alloc] init];
    
    cycleV.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:cycleV];
    
    //    MARK: 创建btnView
    NSArray *imageNameArr = @[@"member_icon_0", @"member_icon_1",@"member_icon_2",@"member_icon_3"];
    
    NSArray *titleArr = @[@"每日签到",@"疯狂秒杀",@"鲜货直供",@"大闸蟹"];
    LBBtnView *btnV = [[LBBtnView alloc] initWithImageNameArr:imageNameArr titleArr:titleArr];
    
//    btnV.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:btnV];
    //    MARK: 布局
    [cycleV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.mas_equalTo(160);
    }];
    
    [btnV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self.contentView);
        make.height.mas_equalTo(80);
    }];
    
    
}

#pragma mark -自定义button
- (void)createButtonWithImageName: (NSString *)imageName title: (NSString *)title tag: (NSString *)tag{
    //    MARK: 创建一个按钮
    UIButton *btn = [[UIButton alloc] init];
    //    MARK: 添加到cell中
    [self.contentView addSubview:btn];
    //    MARK: 生成一个图片和文字混合的NSAttributedString（图文混排）
    NSAttributedString *str = [NSAttributedString cz_imageTextWithImage:[UIImage imageNamed:imageName] imageWH:44 title:title fontSize:12 titleColor:[UIColor blackColor] spacing:7];
    //    MARK: 设置按钮的nsattributed属性
    [btn setAttributedTitle:str forState:UIControlStateNormal];
    //    MARK: 设置按钮的大小
    [btn sizeToFit];
    //    MARK: 设置按钮的自动换行
    btn.titleLabel.numberOfLines = 0;
    //    MARK: 设置按钮的文本对齐方式
    btn.titleLabel.textAlignment = NSTextAlignmentCenter;
    //    MARK: 设置按钮的点击事件
    [btn addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark - btn 的点击事件
- (void)btnClickAction: (UIButton *)btn{

    
    
}
#pragma mark - 布局
- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    NSLog( @"%@",self.subviews);
    
    
    
}

@end
